/**
*	插件：流程模块录入主JS
*	开发者：雨中磐石
*	地址：www.rockoa.com
*	日期：2023-07-17
*/

js.input = {
	allinput:{},
	init:function(){
	},
	getobj:function(id){
		return this.allinput[id];
	},
	create:function(cans){
		var me = this;
		var defv = js.applyIf(cans,{
			rand:js.getrand(),
			data:{}, //表单数据
			savedata:{}, //保存的数据
			num:'',  //模块编号
			cnum:'',
			funitid:'',
			mid:0,
			view:'',
			moders:{},
			fileshow:{},
			inputparams:{},
			filedata:[],
			store:{},
			modejs:'', //录入js
			saveurl:'',
			tdleft:'width:90px;color:#555555;text-align:right;',
			isinput:false,  //是不是录入页
			isedit:false,
			saveparams:{}, 	//其他参数
			subdata:{},
			onsubmitbefore:function(){},
			onsubmitsuccess:function(){},
			onselectdatabefore:function(){},
			onselectdata:function(){},
			onsuccess:function(){},
			onchangedate:function(){},
			initbodys:function(){},
			onshow:function(){},
			oninputstring:function(){return ''},
			issave:false,
			fieldsarr:[]
		});
		for(var i in defv)this[i]=defv[i];
		var rand  = this.rand;
		
		this.init = function(){
			if(this.mid>0)this.isedit = true;
			if(this.num && this.modejs){
				var url = 'res/flow/'+this.num+'.js';
				js.importjs(url, function(){
					me.lurjsshow();
				});
			}else{
				this.lurjsshow();
			}
			js.input.allinput[rand] = this;
		};
		
		this.lurjsshow = function(){
			var key  = ''+this.num+'_input';
			if(js[key]){
				var nobj = new js[key]();
				for(var i in nobj)this[i] = nobj[i];
			}
			$('#'+this.view+'').html(this.showinput());
			this.initbodys();
			this.onshow();
			this.chulifile();
			
		};
		
		this.showinput = function(){
			var farr   		= this.fieldsarr,bt,zdsm,len = farr.length,zfarr={},ftype,type,arr,d,i,fid;
			this.formname 	= 'inputmyform_'+rand+'';
			this.fieldsobj	= {};
			for(i=0;i<len;i++){
				d 	 = farr[i];
				d.xu = i;
				this.fieldsobj[d.fields] = d;
				if(d.islu=='0')continue;
				ftype	= d.ftype;
				if(!ftype)ftype = 'base';
				if(!zfarr[ftype])zfarr[ftype]=[];
				if(d.islu==1)zfarr[ftype].push(d);
			}
			this.gongshistr = {};
			var str='<form name="'+this.formname+'" autocomplete="off">',inputstr;
			for(ftype in zfarr){
				arr = zfarr[ftype];
				len = arr.length;
				//if(ftype!='base')str+='<div style="color:#888888;font-size:14px;border-bottom:1px #eeeeee solid;margin:5px" align="center">'+ftype+'</div>';
				str+='<table width="100%">';
				for(i=0;i<len;i++){
					d = arr[i];bt= '';zdsm=d.zdsm;
					type = d.fieldstype;
					fid	 = d.fields;
					if(fid=='sort')zdsm+='数字越大越靠后';
					if(this.store && this.store[fid])d.store = this.store[fid];
					if(d.isbt==1)bt='<font color=red>*</font>';
					if(zdsm)bt+='<font class="cursor" onclick="js.input.alert(\''+jm.base64encode(zdsm)+'\',\''+jm.base64encode(d.name)+'\')"><i class="icon-info-sign"></i></font>';
					inputstr = this.inputstring(d);
					if(type=='hidden'){
						str+='<tr style="display:none">';
						str+='<td>'+inputstr+'</td>';
						str+='</tr>';
					}else{
						str+='<tr>';
						str+='<td><div style="'+this.tdleft+'">'+bt+''+d.name+'</div></td>';
						str+='<td width="95%" style="padding:8px"><div>'+inputstr+'</div></td>';
						str+='</tr>';
					}
					if(type=='uploadfile'){
						val = this.data[fid];
						if(val)this.fileshow[fid] = val;
					}
					if(type=='subdata'){
						if(this.subdata[fid])this.subdata[fid].xu = d.xu;
					}
					if(d.gongshi){
						this.gongshistr[fid] = d.gongshi;
					}
				}
				str+='</table>';	
			}
			str+='</form>';
			return str;
		};
		
		this.chulifile = function(){
			var fid,gshi,b1,i,sid,o1;
			if(this.isedit && this.subdata)for(fid  in this.subdata){
				this.xiangshow(this.subdata[fid],fid,false);
			}
			this.chulifiles();
			if(this.gongshistr)for(fid in this.gongshistr){
				gshi = this.gongshistr[fid];
				b1	 = this.pipematch(gshi);
				for(i=0;i<b1.length;i++){
					sid = b1[i];
					o1  = this.form(sid);
					if(o1)$(o1).blur(function(){me.inputblur(this);});
				}
			}
		}
		this.chulifiles = function(){
			var len = this.filedata.length;
			if(len>0)importjs('rockfile','create', function(){
				me.fileviewall();
			});
		}
		
		this.fileviewall = function(){
			js.rockfile.setfiledata(this.filedata);
			var fid,vid;
			for(fid in this.fileshow){
				if(this.fileshow[fid]){
					vid = 'uploadfile_'+fid+'_'+rand+'';
					$('#'+vid+'').html('');
					js.rockfile.fileviewshow(this.fileshow[fid],vid, fid.indexOf('nodel')==-1);
					this.fileshow[fid]='';
				}
			}
		}
		
		this.inputblur = function(o){
			var na = o.name,fid,gstr;
			for(fid in this.gongshistr){
				gstr = this.gongshistr[fid];
				if(gstr.indexOf('{'+na+'}')>-1)this.rungongshis(fid, gstr);
			}
		}
		
		this.submit = function(o1){
			var farr   = this.fieldsarr,i,d,fid,type,val;
			var fdata  = js.getformdata(this.formname);
			var astr = this.onsubmitbefore(fdata);
			if(astr){
				if(typeof(astr)=='string'){js.show.error(astr);return;}
				if(typeof(astr)=='object')for(i in astr)fdata[i] = astr[i];
			}
			var stime,etime;
			var isfid = this.inputparams.issubdata;
			if(isfid){
				if(!this.form(isfid)){js.show.error(''+isfid+'字段不存在');return;}
			}
			for(i=0;i<farr.length;i++){
				d = farr[i];fid = d.fields;type = d.fieldstype;
				if(d.islu=='0')continue;
				if(fid=='startdt')stime = d.name;
				if(fid=='enddt')etime = d.name;
				
				if(d.isbt=='0' || type=='hidden')continue;
				val = fdata[fid];
				if(isempt(val)){
					js.show.error(''+d.name+'不能为空');
					if(this.form(fid))this.form(fid).focus();
					return;
				}
			}
			if(stime && etime && fdata.startdt && fdata.enddt && fdata.startdt>fdata.enddt){
				js.show.error(''+etime+'不能小于'+stime+'');
				return;
			}
			js.show.hide();
			this.savedata= fdata;
			var ztv 	 = o1.innerHTML;
			var url 	 = this.saveurl;
			if(!url)url	 = 'api/flow/inputsave?num='+this.num+'&mid='+this.mid+'';
			js.ajax.post({
				url: url,
				data:fdata,
				cnum:this.cnum,
				funitid:this.funitid,
				loading:''+ztv+'中...',
				loadsuccess:''+ztv+'成功',
				btnobj:o1,
				onsuccess:function(ret){
					me.savesuccess(ret.data);
				},
				onerror:function(){
					
				}
			});
		}
		
		this.savesuccess = function(da){
			this.issave = true;
			this.savedata.id = da.mid;
			this.formdisabled();
			this.onsubmitsuccess();
			this.subdatashow();
			this.onsuccess();
		}
		
		this.subdatashow=function(){
			var call = this.inputparams.issubdata_call;
			if(!call)return;
			try{window[call](this);}catch(e){}
		}
		
		this.formdisabled=function(){
			$(document[this.formname]).find('*').attr('disabled', true);
		}
		
		this.form = function(fid){
			return jsform(fid, this.formname);
		}
		
		this.select = function(fid,lx,xu1){
			if(this.issave)return;
			var fa  = this.fieldsobj[fid];
			var a1,dval,dastr = fa.data;
			if(lx==0){
				var cans = {
					title:fa.name,
					changetype:fa.fieldstype,
					nameobj:this.form(fid),
					idobj:false,
					cnum:this.cnum
				}
				if(dastr){
					a1  = dastr.split(',');
					if(a1[0]){
						fid = a1[0];
						cans.idobj = this.form(fid);
					}
				}
				importjs('changeuser','create', cans);
			}
			if(lx==1){
				this.form(fid).value='';
				if(dastr){
					a1  = dastr.split(',');
					if(a1[0]){
						fid = a1[0];
						this.form(fid).value='';
					}
				}
			}
			if(lx==2){
				var bstr	= this.onselectdatabefore(fid,fa);
				if(bstr && typeof(bstr)=='string'){
					js.show.error(bstr);
					return;
				}
				var url = 'api/flow/loadstore?num='+this.num+'&zdid='+fa.id+'';
				if(bstr && typeof(bstr)=='object')for(var i in bstr)url+='&'+i+'='+bstr[i]+'';
				var cans = {
					url:url,
					title:fa.name,
					checked:false,
					cnum:this.cnum,
					fieldsv:fid,
					onselect:function(sel,sna,sid){
						me.onselectdata(this.fieldsv, sel,sna,sid);
					},
					nameobj:this.form(fa.fields),
					idobj:false
				}
				if(dastr){
					a1  = dastr.split(',');
					if(a1[1]){
						fid = a1[1];
						cans.idobj = this.form(fid);
					}
				}
				importjs('selectdata','create',cans);
			}
			if(lx==3){
				this.form(fid).value='';
				if(dastr){
					a1  = dastr.split(',');
					if(a1[1]){
						fid = a1[1];
						var o2 = this.form(fid);
						if(o2){
							dval = $(o2).attr('dvalue');
							if(isempt(dval))dval = '';
							o2.value = dval;
						}
					}
				}
			}
			if(lx==4){
				this.form(fid).value='';
				get(fid+rand+'_img').src='images/noimg.jpg';
			}
			if(lx==5){
				importjs('rockfile','changeface',{
					name:fa.name,
					fields:fid+rand,
					cnum:this.cnum
				});
			}
			if(lx==6){
				importjs('datepicker','open',{
					inputobj:this.form(fid),
					view:fa.fieldstype,
					fid:fid,
					onchange:function(v){
						me.onchangedate(this.fid);
					}
				});
			}
			if(lx==7){
				importjs('rockfile','uploafile',{
					name:fa.name,
					uptype:fa.data,
					inputobj:this.form(fid),
					cnum:this.cnum,
					view:'uploadfile_'+fid+'_'+rand+''
				});
			}
			if(lx==8){
				var hei = winHb()-160,wei=winWb()-40;
				js.modal.main({
					title:fa.name,
					width:winWb()-20,
					height:hei,
					action:'textareamain',
					html:'<div style="padding:5px;display:flex"><textarea id="textareamain_input" style="height:'+hei+'px;flex:1" class="textarea"></textarea></div>',
					btn:[{text:'确定'}]
				});
				$('#textareamain_input').val(this.form(fid).value);
				$('#textareamain_btn0').click(function(){
					me.form(fid).value = $('#textareamain_input').val();
					js.modal.close('textareamain');
				});
			}
			if(lx==9){
				this.opensub(fid,0);
			}
			if(lx==10){
				var da = this.subdata[fid].data[xu1];
				this.opensub(fid, da.id);
			}
			if(lx==11){
				var da = this.subdata[fid].data[xu1];
				js.modal.confirm({
					msg:'确定要删除此记录吗？'
				},function(jg){
					if(jg=='yes')me.opensub(fid, da.id, true);
				});
			}
		}
		this.opensub = function(fid,mid, bo){
			var fa  = this.fieldsobj[fid];
			var a1,dastr = fa.data;
			a1  = dastr.split(',');
			var fidv  = a1[1],dav={};
			if(!fidv)fidv='mid';
			dav[fidv] = this.form(''+fid+'_value').value;
			var rnd	  = 'rnd'+js.getrand()+'';
			var cans  = {
				cnum:this.cnum,
				name:fa.name,
				num:a1[0],
				fieldsid:fa.id,
				fieldsval:dav[fidv],
				issubdata:fidv,
				issubdata_call:rnd,
				ismodal:true,
				mid:mid
			}
			if(bo){
				js.ajax.get({
					url:'api/flow/delete',
					loading:'删除中...',
					loadsuccess:'删除成功',
					data:{
						mid:mid,
						cnum:this.cnum,
						num:a1[0]
					},
					onsuccess:function(ret){
						me.subdatacall({
							inputparams:{
								fieldsid:cans.fieldsid,
								fieldsval:cans.fieldsval
							}
						});
					}
				})
				return;
			}
			xcy.openinput(cans,dav);
			window[rnd]=function(obj){me.subdatacall(obj);}
		}
		this.subdatacall = function(obj){
			var inpa 	= obj.inputparams
			js.ajax.get({
				url:'api/flow/subdata',
				data:{
					mid:this.mid,
					num:this.num,
					zdid:inpa.fieldsid,
					mids:inpa.fieldsval
				},
				cnum:this.cnum,
				funitid:this.funitid,
				onsuccess:function(ret){
					var da = ret.data;
					me.xiangshow(da,da.fieldssub,true);
					me.chulifiles();
					me.rungongshi();
				}
			});
		}

		this.xiangshow = function(da,fields,bo){
			if(bo)this.subdata[fields] = da;
			var s = '',i,d,j,len,jlen,d1,fid,val,type;
			var view = 'subdataview_'+fields+'_'+rand+'';
			var farr = da.fieldsarr,data = da.data,filedata = da.filedata;
			len  = data.length;
			jlen = farr.length;
			for(i=0;i<len;i++){
				d = data[i];
				s+='<div class="textarea" id="'+view+'_'+d.id+'" style="margin-bottom:8px;padding:0px;height:auto;width:auto">';
				s+='<div style="padding:5px;font-size:12px;background:#e1e1e1">'+da.name+''+(i+1)+'';
				s+='&nbsp;<a href="javascript:;" class="fontsize12" onclick="js.input.select(\''+fields+'\',10,\''+rand+'\','+i+')" class="zhu">编辑</a> <a href="javascript:;" class="fontsize12" onclick="js.input.select(\''+fields+'\',11,\''+rand+'\','+i+')" class="zhu">删</a>';
				s+='</div>';
				s+='<div style="padding:8px">';
				for(j=0;j<jlen;j++){
					d1 = farr[j];
					if(d1.iszs!='1')continue;
					fid= d1.fields;
					if(fid==da.fieldskey)continue;
					val= d[fid];
					type=d1.fieldstype;
					if(type=='uploadfile' && val){
						fid= ''+fields+'_'+fid+''+d.id+'nodel';
						this.fileshow[fid] = val;
						val='<span id="uploadfile_'+fid+'_'+rand+'">'+val+'</span>';
					}
					s+='<div><font color="#555555">'+d1.name+'：</font>'+val+'</div>';
				}
				s+='</div>';
				s+='</div>';
			}
			$('#'+view+'').html(s);
			if(da.datastr && this.form(fields))this.form(fields).value = da.datastr;
			len = filedata.length;
			for(i=0;i<len;i++)this.filedata.push(filedata[i]);
		}
		
		//运行公式
		this.rungongshi=function(){
			var fid,gstr;
			for(fid in this.gongshistr){
				gstr = this.gongshistr[fid];
				this.rungongshis(fid, gstr);
			}
		}
		this.rungongshis=function(fid,gongshi){
			if(!this.form(fid))return;
			var b1 = this.pipematch(gongshi,1),i,str='',s2,b2,a1,sub,sid,sda,j,jlen,k,val;
			for(i=0;i<b1.length;i++){
				b2 = this.pipematch(b1[i],0);
				sid= b2[0].split('.')[0];
				sub= this.subdata[sid];
				if(!sub)continue;
				str = '';
				sda = sub.data;
				jlen= sda.length;
				for(j=0;j<jlen;j++){
					if(j>0)str+='+';
					s2  = b1[i];
					str+='(';
					for(k=0;k<b2.length;k++){
						a1 = b2[k].split('.');
						val= sda[j][a1[1]];
						if(isempt(val))val='0';
						s2 = s2.replace('{'+b2[k]+'}',val);
					}
					str+=s2;
					str+=')';
				}
				gongshi = gongshi.replace('['+b1[i]+']', '('+str+')');
			}
			b1 = this.pipematch(gongshi,0);
			for(i=0;i<b1.length;i++){
				val = this.form(b1[i]);
				if(val){
					val = val.value;
					gongshi = gongshi.replace('{'+b1[i]+'}', ''+val+'');
				}
			}
			try{
				val = eval(gongshi);
				this.form(fid).value = val;
			}catch(e){
				js.show.error(''+gongshi+'公式有错');
			}
		}
		this.pipematch=function(str,lx){
			var star = str.match(/\{(.*?)\}/gi);
			if(lx==1)star = str.match(/\[(.*?)\]/gi);
			var b 	 = [],i;
			if(star)for(i=0;i<star.length;i++){
				b.push(star[i].substr(1, star[i].length-2));
			}
			return b;
		}
		
		this.inputstring = function(d){
			var s= '',type=d.fieldstype,attr=d.attr,val=d.dev,fid=d.fields,fids,dastr=d.data,i,d1,sel,dev=d.dev,a1;
			var da 		= this.data,isedit 	= this.isedit;
			if(isedit)val = '';
			if(da && typeof(da[fid])!='undefined')val = da[fid];
			if(this.oninputstring){
				s = this.oninputstring(d,val);
				if(s)return s;
			}
			var store;
			if(this.store[fid])store = this.store[fid];
			var wei = '96%',sty='';
			if(type=='checkbox'){
				if(val=='1')attr+=' checked';
				s= '<label><input name="'+fid+'" '+attr+' type="checkbox" value="1">'+d.placeholder+'</label>';
			}else if(type=='checkboxall'){
				if(val)val = ','+val+',';
				if(typeof(store)=='object')for(i=0;i<store.length;i++){
					d1 = store[i];
					sel= '';
					if(val && val.indexOf(','+d1.value+',')>-1)sel=' checked';
					s+='<label><input name="'+fid+'[]"'+sel+' type="checkbox" value="'+d1.value+'">'+d1.name+'</label><br>';
				}
			}else if(type=='radio'){
				if(typeof(store)=='object')for(i=0;i<store.length;i++){
					d1 = store[i];
					sel= '';
					if(val && val==d1.value)sel=' checked';
					s+='<label><input name="'+fid+'"'+sel+' type="radio" value="'+d1.value+'">'+d1.name+'</label><br>';
				}
			}else if(type=='number'){
				s= '<input name="'+fid+'" '+attr+' onblur="js.number(this)" onfocus="js.focusval=this.value" type="number" style="width:'+wei+';'+sty+'" value="'+val+'" placeholder="'+d.placeholder+'" class="input">';
			}else if(type=='select' || type=='rockcombo'){
				s= '<select name="'+fid+'" '+attr+' style="width:99.8%;'+sty+'" class="input">';
				s+='<option value="'+dev+'">-请选择-</option>';
				if(typeof(store)=='object')for(i=0;i<store.length;i++){
					d1 = store[i];
					sel= (d1.value==val)?'selected':'';
					if(d1.optgroup){
						if(d1.optgroup=='start')s+='<optgroup label="'+d1.name+'">';
						if(d1.optgroup=='end')s+='</optgroup>';
					}else{
						s+='<option '+sel+' value="'+d1.value+'">'+d1.name+'';
						if(d1.subname)s+='('+d1.subname+')';
						s+='</option>';
					}
				}
				s+='</select>';
			}else if(type=='textarea' || type=='htmlediter'){	
				s= '<textarea class="textarea" name="'+fid+'" '+attr+' style="width:'+wei+';'+sty+'" placeholder="'+d.placeholder+'">'+val+'</textarea>';
				s+='<a style="font-size:12px" onclick="js.input.select(\''+fid+'\',8,\''+rand+'\')" clsss="zhu" href="javascript:;"><i class="icon-fullscreen"></i>全屏输入</a>';
			}else if(type.indexOf('selectdata')==0){
				var val2='';
				if(!isedit && dev){
					a1  = dev.split('|');
					val = a1[0];
					if(a1[1])val2 = a1[1];
				}
				s='<table width="100%"><tr>';
				s+='<td width="100%"><input name="'+fid+'" '+attr+' value="'+val+'" style="width:100%;'+sty+'" placeholder="'+d.placeholder+'" readonly class="input">';
				if(dastr){
					a1  = dastr.split(',');
					if(a1[1]){
						fids= a1[1];
						val = val2;
						if(da && typeof(da[fids])!='undefined')val = da[fids];
						s+='<input name="'+fids+'" dvalue="'+val2+'" value="'+val+'" type="hidden">';
					}
				}
				s+='</td><td nowrap class="webbtn-group"><button type="button" onclick="js.input.select(\''+fid+'\',3,\''+rand+'\')" style="border-radius:0" class="webbtn webbtn-default"><i class="icon-remove"></i></button><button type="button" onclick="js.input.select(\''+fid+'\',2,\''+rand+'\')" class="webbtn webbtn-default"><i class="icon-search"></i></button></td>';
				s+='</tr></table>';
				
				/*
				s='<div style="display:flex" class="webbtn-group">';
				s+='<input name="'+fid+'" '+attr+' value="'+val+'" style="width:100%;'+sty+'" placeholder="'+d.placeholder+'" readonly class="input">';
				s+='<button type="button" onclick="js.input.select(\''+fid+'\',3,\''+rand+'\')" style="border-radius:0" class="webbtn webbtn-default"><i class="icon-remove"></i></button>';
				s+='<button type="button" onclick="js.input.select(\''+fid+'\',2,\''+rand+'\')" class="webbtn webbtn-default"><i class="icon-search"></i></button>';
				s+='</div>';
				*/
			}else if(type.indexOf('change')==0){
				s='<table width="100%"><tr>';
				s+='<td width="100%"><input name="'+fid+'" '+attr+' value="'+val+'" style="width:100%;'+sty+'" placeholder="'+d.placeholder+'" readonly class="input">';
				if(dastr){
					a1  = dastr.split(',');
					if(a1[0]){
						fids = a1[0];
						val = '';
						if(da && typeof(da[fids])!='undefined')val = da[fids];
						s+='<input name="'+fids+'" value="'+val+'" type="hidden">';
					}
				}
				s+='</td><td nowrap class="webbtn-group"><button type="button" onclick="js.input.select(\''+fid+'\',1,\''+rand+'\')" style="border-radius:0" class="webbtn webbtn-default"><i class="icon-remove"></i></button><button type="button" onclick="js.input.select(\''+fid+'\',0,\''+rand+'\')" class="webbtn webbtn-default"><i class="icon-search"></i></button></td>';
				s+='</tr></table>';
				
				//s='<div style="display:flex" class="webbtn-group">';
				//s+='<input name="'+fid+'" '+attr+' value="'+val+'" style="width:100%;'+sty+'" placeholder="'+d.placeholder+'" readonly class="input">';
				//s+='</div>';
			}else if(type=='uploadimg'){
				var imgurl = 'images/noimg.jpg';
				if(val)imgurl = val;
				s= '<input name="'+fid+'" id="'+fid+''+rand+'" value="'+val+'" type="hidden">';
				s+='<div><img src="'+imgurl+'" onclick="js.viewimg(this)" id="'+fid+''+rand+'_img" height="100" width="100"></div>';
				s+='<div><span class="webbtn-group">';
				s+='<button type="button" onclick="js.input.select(\''+fid+'\',4,\''+rand+'\')" class="webbtn webbtn-mini webbtn-default">×</button>';
				s+='<button type="button" onclick="js.input.select(\''+fid+'\',5,\''+rand+'\')" class="webbtn webbtn-mini webbtn-default">选择</button>';
				s+='</span></div>';
			}else if(type=='uploadfile'){
				var vid = 'uploadfile_'+fid+'_'+rand+'';
				s= '<input name="'+fid+'" value="'+val+'" id="'+vid+'_input" type="hidden">';
				s+='<div style="width:'+wei+';" id="'+vid+'"></div>';
				s+='<div><button type="button" onclick="js.input.select(\''+fid+'\',7,\''+rand+'\')" class="webbtn webbtn-mini webbtn-default"><i class="icon-folder-close-alt"></i> 选文件...</button></div>';
			}else if(type.indexOf('date')==0 || type=='month'){
				s= '<input name="'+fid+'" '+attr+' value="'+val+'" style="width:'+wei+';'+sty+'" placeholder="'+d.placeholder+'" readonly onclick="js.input.select(\''+fid+'\',6,\''+rand+'\')" class="input input-date">';
			}else if(type=='hidden'){
				s= '<input name="'+fid+'" value="'+val+'" type="hidden">';
			}else if(type=='subdata'){
				s ='<div id="subdataview_'+fid+'_'+rand+'"></div>';
				s+='<button type="button" onclick="js.input.select(\''+fid+'\',9,\''+rand+'\')" class="webbtn webbtn-mini webbtn-default">＋新增</button>';
				s+='<input name="'+fid+'" value="'+val+'" type="hidden">';
				var s1d = parseInt(Math.random()*9999);
				s+='<input name="'+fid+'_value" value="-'+s1d+'" type="hidden">';
			}else{
				s= '<input name="'+fid+'" '+attr+' value="'+val+'" type="text" style="width:'+wei+';'+sty+'" placeholder="'+d.placeholder+'" class="input">';
			}
			return s;
		}
	
		this.init();
	},
	
	
	
	
	alert:function(sm,na){
		js.modal.alert({
			title:jm.base64decode(na),
			msg:jm.base64decode(sm),
			btntext:'知道了'
		});
	},
	

	select:function(xu,lx,rnd,xu1){
		var obj 	= this.getobj(rnd);
		obj.select(xu,lx,xu1);
	},
	
	//打开录入页
	open:function(cans,data){
		var can  = {num:cans,mid:0,ismodal:false,name:'',tableid:'',callback:''}
		if(typeof(cans)=='string'){
			can.num = cans;
		}else{
			for(var i in cans)can[i]=cans[i];
		}
		var params = can;
		if(data)params.data = data;
		var lx = (can.mid==0) ? '新增':'编辑';
		var bt = ''+lx+'';
		if(can.name)bt=''+can.name+'('+lx+')';
		if(can.ismodal){
			this.openmodal(can, params, bt);
		}else{
			xcy.openkey({url:'flow/input','name':bt, params:params});
		}
	},
	openmodal:function(can, params, bt){
		if(get('flowinput_'+can.num+'_main')){
			js.show.error('请勿重复打开');
			return;
		}
		js.modal.main({
			width:500,
			height:200,
			bbar:'none',
			action:'flowinput_'+can.num+'',
			title:bt,
			html:'<div id="inputview_'+can.num+'"><div align="center" style="line-height:100px">'+js.show.ling(40)+'</div></div>'
		});
		xcy.addcont('flow/input','inputview_'+can.num+'',params);
	},
	close:function(bh){
		js.modal.close('flowinput_'+bh+'');
	},
	resize:function(bh){
		js.modal.resize('flowinput_'+bh+'');
	}
}